53655e0931204b316b0cbe60a99f09af6c67e186,src/main/java/net/sf/oval/configuration/annotation/AnnotationsConfigurer.java,AnnotationsConfigurer,configureMethodChecks,#ClassConfiguration#,137
Before Change
*/
final List<Check> returnValueChecks = getCollectionFactory().createList(2);
final List<PreCheck> preChecks = getCollectionFactory().createList(2);
final List<PostCheck> postChecks = getCollectionFactory().createList(2);
boolean preValidateThis = false;
boolean postValidateThis = false;
After Change
*/
protected void configureMethodChecks(final ClassConfiguration classCfg)
{
final CollectionFactory cf = getCollectionFactory();
List<Check> returnValueChecks = cf.createList(2);
List<PreCheck> preChecks = cf.createList(2);
List<PostCheck> postChecks = cf.createList(2);
for (final Method method : classCfg.type.getDeclaredMethods())
{
/*
* determine method return value checks and method pre/post
* conditions
*/
boolean preValidateThis = false;
boolean postValidateThis = false;
// loop over all annotations
for (final Annotation annotation : ReflectionUtils.getAnnotations(method,
Boolean.TRUE.equals(classCfg.inspectInterfaces)))
if (annotation instanceof Pre)
{
final PreCheck pc = new PreCheck();
pc.configure((Pre) annotation);
preChecks.add(pc);
}
else if (annotation instanceof PreValidateThis)
preValidateThis = true;
else if (annotation instanceof Post)
{
final PostCheck pc = new PostCheck();
pc.configure((Post) annotation);
postChecks.add(pc);
}
else if (annotation instanceof PostValidateThis)
postValidateThis = true;
else if (annotation.annotationType().isAnnotationPresent(Constraint.class))
returnValueChecks.add(initializeCheck(annotation));
else if (annotation.annotationType().isAnnotationPresent(Constraints.class))
initializeChecks(annotation, returnValueChecks);
/*
* determine parameter checks
*/
final List<ParameterConfiguration> paramCfg = _createParameterConfiguration(
ReflectionUtils.getParameterAnnotations(method, Boolean.TRUE.equals(classCfg.inspectInterfaces)),
method.getParameterTypes());
// check if anything has been configured for this method at all
if (paramCfg.size() > 0 || returnValueChecks.size() > 0 || preChecks.size() > 0 || postChecks.size() > 0
|| preValidateThis || postValidateThis)
{
if (classCfg.methodConfigurations == null) classCfg.methodConfigurations = cf.createSet(2);
final MethodConfiguration mc = new MethodConfiguration();
mc.name = method.getName();
mc.parameterConfigurations = paramCfg;
mc.isInvariant = ReflectionUtils.isAnnotationPresent(method, IsInvariant.class,
Boolean.TRUE.equals(classCfg.inspectInterfaces));
mc.preCheckInvariants = preValidateThis;
mc.postCheckInvariants = postValidateThis;
if (returnValueChecks.size() > 0)
{
mc.returnValueConfiguration = new MethodReturnValueConfiguration();
mc.returnValueConfiguration.checks = returnValueChecks;
returnValueChecks = cf.createList(2); // create a new list for the next method having return value checks
}
if (preChecks.size() > 0)
{